In many fields, error prevention enables a huge cost savings over error correction and early detection of errors in general leads to easier correction. For example, in writing software and firmware code it is much harder to correct defects late in the programming cycle as opposed to defect prevention through code inspections and testing. Another example field is circuit design, in which correction of design and production problems is problematic and costly. Related examples of fields in which error detection is necessary are the teaching of natural languages (e.g. French, English) and technical writing.
Tools exist for testing circuit designs; however generally each tool operates independently. Though automatic grammar checkers exist for natural languages, they are limited in scope. Hence, technical documents generally are also reviewed by editors.
Much research has been done to increase awareness of typical coding errors and to develop systematic methods to find and correct them. Defect classification research focuses on the identification of patterns of errors. There exist many known patterns typical of software code, for example, sort algorithms. These similar code patterns may lead to similar types of coding errors, also known as anti-patterns. Another type of error is “mutation”, common errors that include misuse of operators, operands and the like. For example, misuse of the operators “=” and “==” may lead to errors since the statement “if (a=b)” will produce different results than “if (a==b)”. Likewise, for example, confusing “<” with “>”, or “<” with “<=”, are common errors. Other examples of mutation include miscoding of loop endpoints, for example, using “1<i<10” instead of “0<i<9”. An example of an anti-pattern is putting the loop test condition outside the loop, hence loosing control of the test condition. Other types of errors may relate to style, for example, the placement of brackets around code blocks.
Code inspection to find errors in software code is now an integral part of software development and testing. When performed manually, a different area of responsibility may be given to each participant, for example, synchronization, style, or security. They review the code looking for errors of that specific type. To aid in this task, there are computer programs available that look for known error types and produce a report of errors (or warnings). Different programs look for different types of errors, for example, mutation errors, anti-patterns, or static analysis. Generally, a code inspection will include a meeting between the code reviewers and the code author during which errors, including any found by a computer program will be reviewed, evaluated, and if necessary corrected. A common method used during manual code inspection is paraphrasing. As the code is inspected, the reviewer may paraphrase parts to ascertain what the programmer meant to write. Code inspection is a tedious task that is only as good as the effort put into finding the errors.